const http=require('http');

const url=require('url');

const server=http.createServer((request,response)=>{

    const url=new URL(request.url,'http://127.0.0.1');
    // console.log(url);
    // console.log(request.method);
    const pathname=url.pathname;
    // console.log(pathname);
    response.setHeader('content-type','text/html;charset=utf-8');
    if(request.method=='GET' && pathname=='/login')
    { response.end('登陆页面');}
    else if(request.method=='GET' && pathname=='/reg')
    {
        response.end('注册页面');
    }
    else{
        response.end('出错了');
    }

   
});

server.listen(8000,()=>{
console.log("服务启动成功");
});